/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mabi.modular.runtime.module.contributions.views;

import com.mabi.modular.runtime.application.IFrontEndApp;
import com.mabi.modular.runtime.module.contributions.Contribution;
import com.vaadin.ui.Component;
import com.vaadin.ui.VerticalLayout;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author Justo Disla
 */
public class ViewImpl extends VerticalLayout implements Contribution{

    protected String zoneName = "";
    protected List<Component> subViews;
    protected boolean isClosable = false;
    private boolean closable = true;
    protected boolean autoLoad = false;
    protected String moduleName = "";

    @Override
    public String getModuleName() {
        return moduleName;
    }

    public void setModuleName(String moduleClass) {
        this.moduleName = moduleClass;
    }
    
    public boolean isAutoLoad() {
        return autoLoad;
    }

    public void setAutoLoad(boolean autoLoad) {
        this.autoLoad = autoLoad;
    }
    
    public boolean isIsClosable() {
        return isClosable;
    }

    public void setIsClosable(boolean isClosable) {
        this.isClosable = isClosable;
    }

    public List<Component> getSubViews() {

        return subViews;
    }

    public void setSubViews(List<Component> subViews) {
        this.subViews = subViews;
    }

    public String getZoneName() {
        return zoneName;
    }

    public void setZoneName(String zoneName) {
        this.zoneName = zoneName;
    }

    @Override
    public void replaceComponent(Component oldComponent, Component newComponent) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Iterator<Component> getComponentIterator() {
        //throw new UnsupportedOperationException("Not supported yet.");
        List<Component> comps = new ArrayList();
        return comps.iterator();
        //return getComponentIterator();
        //return null;
    }

    public void setClosable(boolean b) {
        closable = b;
    }

    public boolean isClosable() {
        return closable;
    }

    @Override
    public String toString() {
        String oToString = super.toString();
        oToString = oToString + this.getCaption();
        return oToString;
    }

    @Override
    public String getCaption() {
        String caption = super.getCaption();
        if(caption.length() > 25){
            caption = caption.substring(0, 25) + "...";
        }
        return caption;
    }

    @Override
    public IFrontEndApp getFrontEndApp() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

   
}
